package bmatch.tech.file;

import bmatch.tech.file.config.JSONProvider;
import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;

import java.io.IOException;
import java.net.URI;

/**
 * Main class.
 */
public class Main {

    public static final String BASE_URI = "http://localhost:8080/cloud/";

    public static void main(String[] args) {
        final HttpServer server = startServer();
        System.out.println(String.format("Jersey app:" + BASE_URI));
    }

    public static HttpServer startServer() {
        final ResourceConfig rc = new ResourceConfig().packages("bmatch.tech");
        // json支持
        rc.register(JSONProvider.class);
        // 文件支持
        rc.register(MultiPartFeature.class);

        return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
    }


}

